/**
 * Created by Administrator on 2017/5/25.
 */
"use strict";
//引入模块
const mongoose = require('mongoose');
const db = require('./db');

// Schema 结构
var BookreviewSchema = new mongoose.Schema({
    brid       :{type:Number,index: true},//brid
    bid        :{type:Number,index: true},//bid
    uid        :{type:Number,index: true},//uid
    title      :{type:String},//标题
    startTime  :{type:String,default:new Date().getTime()},//评论时间
    cnt     :{type:String},//内容
    num    :{type : Number,default:0},//回复数
    hot    :{type:String,default:"F"}//热门
});

BookreviewSchema.statics.findFn = function(obj,obj1, callback) {
    return this.model('Bookreview').find(obj, callback).sort(obj1);
};
BookreviewSchema.statics.findFnLimit = function(obj,obj1,num1,callback) {
    return this.model('Bookreview').find(obj).sort(obj1).limit(num1).exec(callback);
};
BookreviewSchema.statics.findLimitSkip = function(obj,num1,num2,obj1,callback) {
    return this.model('Bookreview').find(obj).limit(num1).skip(num2).sort(obj1).exec(callback);
};
BookreviewSchema.statics.findSortOne = function(obj,obj1,callback) {
    return this.model('Bookreview').findOne(obj).sort(obj1).exec(callback);
};
BookreviewSchema.statics.updateFn = function(obj,obj1,callback) {
    return this.model('Bookreview').update(obj,obj1).exec(callback);
};
BookreviewSchema.statics.findConut = function(obj,callback) {
    return this.model('Bookreview').find(obj).count().exec(callback);
};

var BookreviewModel = db.model('Bookreview', BookreviewSchema);

module.exports=BookreviewModel;